<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/website template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>TemplateMaschine - an open source template engine for C#</title>
<!-- InstanceEndEditable -->
<link media=all href="style.css" type=text/css rel=stylesheet>
<link media=all href="csharp.css" type=text/css rel=stylesheet>
<script type="text/javascript">
	/*<![CDATA[*/
<!--

  // JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(2));
	}
	return r;
}
  // JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s)	{	//
	location.href=UnCryptMailto(s);
}
		
		// JS function for mouse-over
	function over(name,imgObj)	{	//
		if (version == "n3" && document[name]) {document[name].src = eval(name+"_h.src");}
		else if (imgObj)	{imgObj.src = eval(name+"_h.src");}
	}
		// JS function for mouse-out
	function out(name,imgObj)	{	//
		if (version == "n3" && document[name]) {document[name].src = eval(name+"_n.src");}
		else if (imgObj)	{imgObj.src = eval(name+"_n.src");}
	}

// -->
	/*]]>*/
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<!-- InstanceParam name="ShowBackReference" type="boolean" value="false" -->
<!-- InstanceParam name="href" type="text" value="http://" -->
<!-- InstanceParam name="ShowFeedback" type="boolean" value="true" -->
</head>
<body>
<div class="pagelayout">
  <div id="header"><A href="http://www.stefansarstedt.com">Dr. Stefan Sarstedt</A><br>
    <!-- InstanceBeginEditable name="PageNavigationPath" -->Projects/TemplateMaschine<!-- InstanceEndEditable --></div>
  <table border="0" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
    <tr>
      <td width="190" height="524" valign="top"><div id="menu">
          <H1>Personal</H1>
          <UL class=list>
            <LI class=listitem><A class=listitem href="index.html">Home</A></LI>
            <LI class=listitem><A class=listitem href="aboutme.html">About me</A></LI>
            <LI class=listitem><A class=listitem href="publications.html">Publications</A></LI>
            <LI class=listitem><A class=listitem href="aboutme.html#contact">Contact</A></LI>
          </UL>
          <H1>Projects</H1>
          <UL class=list>
            <LI class=listitem><A class=listitem href="http://activecharts.informatik.uni-ulm.de">ActiveCharts</A></LI>
            <LI class=listitem><A class=listitem href="templatemaschine.html">TemplateMaschine</A></LI>
          </UL>
          <H1>Teaching</H1>
          <UL class=list>
<!--            <LI class=listitem><A class=listitem href="teaching_current.html">Current</A></LI>-->
            <LI class=listitem><A class=listitem href="teaching.html">Past</A></LI>
          </UL>
        </div></td>
      <td width="600" valign="top"><div class="block">
          <h1 class="block_title"><!-- InstanceBeginEditable name="ContentTitleImage" --><img src="images/templatemaschine_title.jpg" width="325" height="29"><!-- InstanceEndEditable --><br>
            <!-- InstanceBeginEditable name="ContentSubtitle" -->An open source template engine for C#<!-- InstanceEndEditable --></h1>
          <p>&nbsp;</p>
          <div class="content"> 
		  
		  <!-- InstanceBeginEditable name="ContentIntroduction" --><!-- InstanceEndEditable -->
		  <!-- InstanceBeginRepeat name="Sections" --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" -->Purpose<!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
                <P>&quot;TemplateMaschine&quot; is a free open source tool which processes templates written in C# and outputs the results to either a file or a string. Other software of this category include <a href="http://www.ericjsmith.net/codesmith/" target="_blank">CodeSmith</a> or the Java-based <a href ="http://jakarta.apache.org/velocity/" target="_blank">Velocity</a> template engine.</P>
                <P>It's a tool perfectly suitable for <a href="http://www.mdsd.info" target="_blank">MDSD</a> (Model Driven Software Development) resp. <a href="http://www.omg.org/mda/" target="_blank">MDA</a> (Model Driven Architecture) and can be used for a variety of applications of code generation including</p>
                <ul>
                  <li>generating code from UML diagrams (e.g. from XMI files) </li>
                  <li>generating stored procedures</li>
                  <li>generate documentation from classes</li>
                  <li>...and much more </li>
                </ul>
                <p>Short-spoken, it can be used to relieve you from all kind of boring and error prone &quot;cut-and-paste&quot; programming.</p>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" -->Features<!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
                <ul>
                  <li>templates use ASP.NET-like syntax (see below for an example)</li>
                  <li>you write your templates in C#, which can also reference other assemblies and import namespaces </li>
                  <li>templates can be called with arguments </li>
                  <li>templates can be loaded from a file or embedded as a resource in an assembly, which is useful if you want to write 'packaged' generators </li>
                  <li>templates can include other templates</li>
                  <li>script blocks with custom functions and variables can be added to a template</li>
                  <li>the template processor is command line based, that's why it's easy to include template processing in build-scripts like <a href="http://nant.sourceforge.net/" target="_blank">NAnt</a></li>
                  <li>it includes error handling, which means that line number and error information are provided in case of syntax errors in your templates (does not yet work well in all cases though, but I think it's nevertheless very useful)</li>
                  <li>intermediate generated template code can be written to a file for debugging purposes</li>
                  <li>it's free and open source (released under <a href="http://www.gnu.org/licenses/licenses.html#LGPL">GNU Lesser General Public License</a>)</li>
                  <li>code is written in C#</li>
                  <li>it's fast</li>
                </ul>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" -->Introductory Example<!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
                <p>We start with a simple example, which consists of the following files:</p>
                <ul>
                  <li>
                    <div class="code"><a href="#download">SampleDriver.cs</a></div>
                    This is the driver application. It loads the template, and calls the <span class="codeinline">generate()</span> method that processes the template. Output is written to 'SampleOutput.txt' </li>
                  <li>
                    <div class="code"><a href="#download">Sample.template</a></div>
                    This is a simple template without arguments</li>
                  <li>
                    <div class="code"><a href="#download">run.bat</a></div>
                    Compiles the application and executes the sample</li>
                </ul>
                <p>So, here's the driver code: </p>
                <DIV class="codeblock">
                  File <a href="#download">SampleDriver.cs</a>:
                    <pre class="csharpcode">
<span class="kwrd">using</span> System;
<span class="kwrd">using</span> TemplateMaschine;

<span class="kwrd">namespace</span> Sample
{
  <span class="kwrd">class</span> Program
  {
    <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
    {
      <span class="rem">// Load a template from file 'Sample.template' </span>
      <span class="rem">// and compile it</span>
      Template myTemplate = <span class="kwrd">new</span> Template(<span class="str">"Sample.template"</span>);

      <span class="rem">// Process the template with no arguments</span>
      <span class="rem">// and write output to file 'SampleOutput.txt'</span>
      myTemplate.Generate(<span class="kwrd">null</span>, <span class="str">"SampleOutput.txt"</span>);
    }
  }
}
</pre>
                    Go to the <a href="#download">[download section]</a> to download the complete source code.
            </DIV>
                <p>Here comes the template: </p>
                <DIV class="codeblock">
                  File <a href="#download">Sample.template</a>:
                    <pre class="csharpcode">
This is the first line
&lt;% <span class="kwrd">string</span>[] greetz = <span class="kwrd">new</span> <span class="kwrd">string</span>[] {<span class="str">"Hello"</span>, <span class="str">"this"</span>, <span class="str">"is"</span>, 
                                <span class="str">"my"</span>, <span class="str">"first"</span>, <span class="str">"template"</span>};
   <span class="kwrd">foreach</span>(<span class="kwrd">string</span> greet <span class="kwrd">in</span> greetz)
   { %&gt;
Here comes the text: &lt;%=greet%&gt;
&lt;% } %&gt;
This is the last line
</pre>
                    Go to the <a href="#download">[download section]</a> to download the complete source code.
            </div>
                <p>Now, call <a href="#download">run.bat</a> which compiles the files and executes the sample driver using the following commands: </p>
                <div class="codeblock">
                    <pre class="cmdline">C:\&gt; csc /t:library TemplateMaschine.cs<br>C:\&gt; csc /t:exe /r:TemplateMaschine.dll SampleDriver.cs<br>C:\&gt; sampledriver.exe</pre>
            </div>
                <p>Now have a look at 'SampleOutput.txt', which should have appeared in your directory: </p>
                <DIV class="codeblock">
                  File 'SampleOutput.txt':
                    <pre class="csharpcode">
This is the first line
Here comes the text: Hello
Here comes the text: this
Here comes the text: is
Here comes the text: my
Here comes the text: first
Here comes the text: template
This is the last line
</pre>
                    Go to the <a href="#download">[download section]</a> to download the complete source code.
                </DIV>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" -->More Examples<!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
                <P>Here are some more examples that show enhanced features (for a complete list of features, see the <a href="#documentation">documentation</a> section):</P>
                <ul>
                  <li><a href="dievorlagenmaschine_ex2.html">Writing templates with arguments and using assemblies</a></li>
                  <li><a href="dievorlagenmaschine_ex3.html">Embedding templates in an assembly</a> </li>
                </ul>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" --><a name="documentation">Documentation</a><!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
			<ul>
			  <li><a href="dievorlagenmaschine_doc.html">Description of  all template elements</a></li>
		      <li><a href="Releases/DieVorlagenMaschine/Doc/index.html" target="_blank">HTML class documentation</a> (generated with <a href="http://ndoc.sourceforge.net">NDoc</a>) </li>
			</ul>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceBeginRepeatEntry -->
            <div class="contenttitle"><!-- InstanceBeginEditable name="SectionTitle" --><a name="download">Download</a><!-- InstanceEndEditable --></div>
            <!-- InstanceBeginEditable name="SectionContent" -->
                <P>Requirements:</P>
                <ul>
                  <li><a href="http://msdn.microsoft.com/netframework/downloads/updates/default.aspx" target="_blank">.NET Framework SDK Version 2.0 Beta 1</a> (required)</li>
                  <li><a href="http://lab.msdn.microsoft.com/vs2005/" target="_blank">Visual Studio .NET 2005</a> (optional) </li>
                </ul>
                <P>Sources can be found  at <a href="http://sourceforge.net/projects/vmaschine/">sourceforge.net project page</a>
                <table width="249" border="0" cellspacing="2" cellpadding="5">
                  <tr>
                    <td width="7">&nbsp;</td>
                    <td><a href="http://sourceforge.net/"><img src="http://sourceforge.net/sflogo.php?group_id=122761&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a></td>
					<td>&nbsp;</td>
                    <!--<td><a href="http://sourceforge.net/donate/index.php?group_id=122761"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /></a></td>-->
                  </tr>
                </table></p>
            <!-- InstanceEndEditable -->
            <div class=separator>&nbsp;</div>
		  
          <!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat --> 
		  
		  <div class="contenttitle">Feedback</div>
		  <p>Please send me your </p>
          <ul>
          	<li><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR><td style="width: 80px"></td><TD></TD><TD VALIGN="BOTTOM" ROWSPAN="2"><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;uwiiguvkqpuBuvghcpuctuvgfv0eqo');">&#64;</a></TD><TD></TD></TR>
<TR><td>suggestions</td><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;uwiiguvkqpuBuvghcpuctuvgfv0eqo');">suggestions</a></TD><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;uwiiguvkqpuBuvghcpuctuvgfv0eqo');">stefansarstedt.com</a></TD></TR>
</TABLE></li>
          	<li><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR><td style="width: 80px"></td><TD></TD><TD VALIGN="BOTTOM" ROWSPAN="2"><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;dwiuBuvghcpuctuvgfv0eqo');">&#64;</a></TD><TD></TD></TR>
<TR><td>bugs reports &nbsp;</td><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;dwiuBuvghcpuctuvgfv0eqo');">bugs</a></TD><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;dwiuBuvghcpuctuvgfv0eqo');">stefansarstedt.com</a></TD></TR>
</TABLE></li>
          	<li><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR><td style="width: 80px"></td><TD></TD><TD VALIGN="BOTTOM" ROWSPAN="2"><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;hggfdcemBuvghcpuctuvgfv0eqo');">&#64;</a></TD><TD></TD></TR>
<TR><td>or feedback &nbsp;</td><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;hggfdcemBuvghcpuctuvgfv0eqo');">feedback</a></TD><TD><a href="javascript:linkTo_UnCryptMailto('ocknvq&lt;hggfdcemBuvghcpuctuvgfv0eqo');">stefansarstedt.com</a></TD></TR>
</TABLE></li>
          </ul>
		  <p>If you like the software I would be very pleased if you donate me an amount of your choice to support my work. Thank you very much in advance!
		  <table width="100" border="0" cellspacing="2" cellpadding="5">
  <tr>
    <td width="7">&nbsp;</td>
    <td>                <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="images/x-click-but04.gif" border="0" name="submit" alt="Donate with PayPal - fast, free of charge and safe!">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcN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SXK226fwRoblsDf0zT9xckLSIeCS4PRTnUIW3oQmVeBDEN8CNOKmflypyHeAOPTPi7opg5a1QJ/xxf4AjV7x7qvFgLikP/A==-----END PKCS7-----
">
</form></p>
</td>
  </tr>
</table>

		  
		  </div>
          <div class="block_footer">
            <div class="itemdesc">This page was last changed on 
              <script language="javascript" type="text/javascript">document.write(document.lastModified);</script>
            </div>
          </div>
        </div></td>
    </tr>
  </table>
</DIV>
</body>
<!-- InstanceEnd --></html>
